import { getOrderTotalFee } from '@/api/order'
import { ref } from 'vue'
import { OrderTotalFee } from './types'

export const useGetOrderTotalFee = () => {
  // 获取总费用加载
  const getOrderTotalFeeLoading = ref(false)

  // 工单总费用
  const orderTotalFee = ref<OrderTotalFee | null>(null)

  /**
   * 获取工单总费用
   * @param {string} id - 工单ID
   */
  const getOrderTotalFeeFn = async (id: string) => {
    getOrderTotalFeeLoading.value = true
    const res = await getOrderTotalFee(id)
    orderTotalFee.value = res.data.data.row
    getOrderTotalFeeLoading.value = false
  }

  return {
    orderTotalFee,
    getOrderTotalFeeLoading,
    getOrderTotalFeeFn,
  }
}
